$authr()

require('../css/mine.less')

require('../font/iconfont.css')

// require('../lib/weui/weui.css')
const axios = require('../lib/axios/axios.js')

// 获取我的页面的数据

document.ready(function () {

    $footerClick();

    const nickName = document.querySelector('#nickName');
    const sign = document.querySelector('#sign');
    const mypic = document.querySelector('#mypic');


    const allMin = document.querySelector('#allMin');
    const allKro = document.querySelector('#allKro');
    
    // 获取用户id
    const data = JSON.parse(localStorage.getExpire('data'))
    let uid = data.user.userId




    axios.get(BASE_URL + '/users/mysportsBadge?userId=' + uid).then(res => {
        // ck
        if (res.data.status == 0) {
            let result = res.data.data

            // 基本信息
            if (result.user.nickname) nickName.innerHTML = result.user.nickname
            if (result.user.sign) sign.innerHTML = result.user.sign
            if (result.user.imgurl) mypic.src = result.user.imgurl

            // 运动信息
            if (result.sports.calorie) allKro.innerHTML = result.sports.calorie
            if (result.sports.times) allMin.innerHTML = result.sports.times
        } else {
            // sb
            $createMask("icon-dingwei1", "网络不稳定!", 1000)
        }

    }).catch(r => {
        $createMask("icon-dingwei1", "网络错误!", 1000)
    })



    // 进入个人主页修改页面
    mypic.addEventListener('click', function () {
        location.href = "./mineInfo.html"
    })

    // 进入数据中心
    document.querySelector('#sportsData').addEventListener('click', function () {
        location.href = './sportsData.html'
    })



    // 退出登录
    let out = document.querySelector('#loginout');
    out.addEventListener('click', function () {
        localStorage.removeItem('data');
        location.href = "./register.html"
    })




})